import requests


class IHRMEMPAPI:

    @classmethod
    def ihrm_add_emp_api(cls, token, add_emp_body):
        add_emp_url = "http://ihrm2-test.itheima.net/api/sys/user"
        add_emp_header = {"Content-Type": "application/json", "Authorization": token}
        add_emp_resp = requests.post(url=add_emp_url, headers=add_emp_header, json=add_emp_body)
        return add_emp_resp

    @classmethod
    def query_emp_api(cls, emp_id, token):
        query_emp_url = "http://ihrm2-test.itheima.net/api/sys/user/" + emp_id
        query_emp_header = {"Authorization": token}
        query_emp_resp = requests.get(url=query_emp_url, headers=query_emp_header)
        return query_emp_resp

    @classmethod
    def modify_emp_api(cls, emp_id, token, query_username):
        modify_emp_url = "http://ihrm2-test.itheima.net/api/sys/user/" + emp_id
        modify_emp_header = {"Content-Type": "application/json",
                             "Authorization": token}
        modify_emp_body = {"username": query_username}
        modify_emp_resp = requests.put(url=modify_emp_url, headers=modify_emp_header, json=modify_emp_body)
        return modify_emp_resp

    @classmethod
    def del_emp_api(cls, emp_id, token):
        del_emp_url = "http://ihrm2-test.itheima.net/api/sys/user/" + emp_id
        del_emp_header = {"Authorization": token}
        del_emp_resp = requests.delete(url=del_emp_url, headers=del_emp_header)
        return del_emp_resp
